package com.dinadi.yidi.ui.fragment;

import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.dinadi.yidi.R;
import com.dinadi.yidi.adapter.ProductSubjectAdapter;
import com.dinadi.yidi.base.BaseFragment;
import com.dinadi.yidi.bean.CreativeProductBean;
import com.dinadi.yidi.bean.ListBean;
import com.dinadi.yidi.bean.ProductSubjectListBean;
import com.dinadi.yidi.bean.ShareBean;
import com.dinadi.yidi.http.HttpListener;
import com.dinadi.yidi.http.interfaces.CommonInterface;
import com.dinadi.yidi.ui.activity.ClassificationActivity;
import com.dinadi.yidi.ui.activity.CreativeHotspotDetailsActivity;
import com.dinadi.yidi.ui.activity.DesignerBrandStoryActivity;
import com.dinadi.yidi.ui.activity.ExhibitionMatchActivity;
import com.dinadi.yidi.ui.activity.LoginActivity;
import com.dinadi.yidi.ui.activity.MyShoppingCartsActivity;
import com.dinadi.yidi.ui.activity.ProductClassificationActivity;
import com.dinadi.yidi.ui.activity.ProductDetailsActivity;
import com.dinadi.yidi.ui.activity.ProductSubjectAllActivity;
import com.dinadi.yidi.ui.activity.SearchProductActivity;
import com.dinadi.yidi.ui.view.DatePopup;
import com.dinadi.yidi.ui.view.FlyBanner;
import com.dinadi.yidi.ui.view.MyListView;
import com.dinadi.yidi.utils.JsonUtil;
import com.dinadi.yidi.utils.SharePreferencesHelper;
import com.dinadi.yidi.utils.ToastUtil;
import com.umeng.analytics.MobclickAgent;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import de.greenrobot.event.EventBus;

/**
 * author: JiaYu.He
 * Date: 2018/2/28   商店橱窗
 * Time: 13:39
 */

public class ShopWindowFragment extends BaseFragment {
    private View view;
    private ImageView img_shopping_cart, img_furniture, img_home_furnishing, img_digital, img_jewellery, img_accessories, img_originality, img_art;
    private RelativeLayout layout_empty, bg_ascending, bg_descending, go_search;
    private TextView tv_confirm, tv_ascending, tv_descending;
    private EditText et_lower_price, et_higher_price;
    private LinearLayout layout_search;
    private FlyBanner banner;
    private Drawable drawable_price, drawable_degree_of_heate;
    private ProductSubjectAdapter productSubjectAdapter;
    private RadioButton rb_comprehensive, rb_price, rb_degree_of_heate;
    private MyListView lv_section;//活动版块
    private List<String> picList;//bananert图片
    private List<Integer> picLocalList;//bananert本地图片
    private List<ProductSubjectListBean> dataBean = new ArrayList<>();
    private List<BaseFragment> fragments = new ArrayList<>();
    private List<RadioButton> radioButtons = new ArrayList<>();
    private AppBarLayout appBarLayout;
    private DatePopup popup;
    private CreativeProductBean bean,bean2;
    private boolean loginState;
    private int heat_temperature = 0;//0,热度升序   1，降序
    private int price_temperature = 0;//0,价格升序   1，降序
    private String token;
    private String categoryId;
    private int lower;
    private int higher;
    private ListBean bannerBean;
    private String lower_price, higher_price;
    private int mIndex;
    private HashMap<String, String> map;


    @Override
    protected void noWifiRefresh() {

    }

    @Override
    protected View getLayout() {
        view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_shop_window, null);
        return view;
    }

    @Override
    protected void initView() {

        changePager(2);
        img_shopping_cart = (ImageView) view.findViewById(R.id.img_shopping_cart);
        banner = (FlyBanner) view.findViewById(R.id.banner);
        lv_section = (MyListView) view.findViewById(R.id.lv_section);
        rb_comprehensive = (RadioButton) view.findViewById(R.id.rb_comprehensive);
        rb_price = (RadioButton) view.findViewById(R.id.rb_price);
        rb_degree_of_heate = (RadioButton) view.findViewById(R.id.rb_degree_of_heate);
        appBarLayout = (AppBarLayout) view.findViewById(R.id.appBarLayout);
        layout_search = (LinearLayout) view.findViewById(R.id.layout_search);
        go_search = (RelativeLayout) view.findViewById(R.id.go_search);
        img_furniture = (ImageView) view.findViewById(R.id.img_furniture);
        img_home_furnishing = (ImageView) view.findViewById(R.id.img_home_furnishing);
        img_digital = (ImageView) view.findViewById(R.id.img_digital);
        img_jewellery = (ImageView) view.findViewById(R.id.img_jewellery);
        img_accessories = (ImageView) view.findViewById(R.id.img_accessories);
        img_originality = (ImageView) view.findViewById(R.id.img_originality);
        img_art = (ImageView) view.findViewById(R.id.img_art);
        productSubjectAdapter = new ProductSubjectAdapter(getActivity(), dataBean);
        lv_section.setAdapter(productSubjectAdapter);
        bean = new CreativeProductBean();
        bean2 = new CreativeProductBean();
        changeImageSize();
        map = new HashMap<String, String>();
    }

    private void changeImageSize() {
        //定义底部标签图片大小
        drawable_price = getResources().getDrawable(R.drawable.icon_default);
        drawable_price.setBounds(0, 0, 30, 50);//第一0是距左右边距离，第二0是距上下边距离，第三69长度,第四宽度
        rb_price.setCompoundDrawables(null, null, drawable_price, null);//只放上面

        drawable_degree_of_heate = getResources().getDrawable(R.drawable.icon_default);
        drawable_degree_of_heate.setBounds(0, 0, 30, 50);//第一0是距左右边距离，第二0是距上下边距离，第三69长度,第四宽度
        rb_degree_of_heate.setCompoundDrawables(null, null, drawable_degree_of_heate, null);//只放上面

    }

    @Override
    public void onResume() {
        super.onResume();
        loginState = SharePreferencesHelper.getInstance(getActivity()).getBoolean("loginState");

    }

    @Override
    protected void initListener() {
        registerClickListener(img_shopping_cart, go_search, img_furniture, img_home_furnishing, img_digital, img_jewellery, img_accessories, img_originality, img_art);
        rb_comprehensive.setOnClickListener(this);
        rb_price.setOnClickListener(this);
        rb_degree_of_heate.setOnClickListener(this);
        banner.setOnItemClickListener(new FlyBanner.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                String targetUrl = bannerBean.getBannerList().get(position).getTargetUrl();
                String type = targetUrl.substring(0, targetUrl.lastIndexOf("="));
                String id = targetUrl.substring(targetUrl.lastIndexOf("=") + 1);
                if (type.equals("http://YiDi_ProductDetail_ProductId")) {
                    /*商品详情*/
                    Intent intent = new Intent(getActivity(), ProductDetailsActivity.class);
                    intent.putExtra("productId", id);
                    startActivity(intent);
                } else if (type.equals("http://YiDi_ProductList_ProductListId")) {
                    /*商品列表*/
                    Intent intent = new Intent(getActivity(), ProductSubjectAllActivity.class);
                    intent.putExtra("proSubId", id);
                    startActivity(intent);

                } else if (type.equals("http://YiDi_GameDetail_GameDetailId")) {
                    /*活动详情*/
                    Intent intent = new Intent();
                    intent.setClass(getActivity(), ExhibitionMatchActivity.class);
                    intent.putExtra("showId", id);
                    startActivity(intent);
                } else if (type.equals("http://YiDi_ArticleDetail_ArticelDetail")) {
                    /*创意热点 文章详情*/
                    Intent intent = new Intent();
                    intent.setClass(getActivity(), CreativeHotspotDetailsActivity.class);
                    intent.putExtra("hotId", id);
                    startActivity(intent);
                } else if (type.equals("http://YiDi_DesignerDetail_DesignerDetailId")) {
                    /*设计师详情id 设计师详情*/
                    Intent intent = new Intent();
                    intent.setClass(getActivity(), CreativeHotspotDetailsActivity.class);
                    intent.putExtra("dUserId", id);
                    startActivity(intent);
                }
            }
        });

    }

    @Override
    protected void clickEvent(View v) {
        switch (v.getId()) {
            case R.id.img_shopping_cart:
                if (loginState == false) {
                    Intent loginIntent = new Intent();
                    loginIntent.setClass(getActivity(), LoginActivity.class);
                    startActivity(loginIntent);
                } else {
                    Intent intent = new Intent(getActivity(), MyShoppingCartsActivity.class);
                    startActivity(intent);
                }

                break;
            case R.id.rb_comprehensive:
                /*综合*/
                setIndexSelected(0);
                selectRadioButton(0);
                appBarLayout.setExpanded(false);//悬浮tab展开
                changeImageSize();
                MobclickAgent.onEvent(getActivity(), "ShopComprehensive", "商店综合");

                break;
            case R.id.rb_price:
                /*价格*/
                appBarLayout.setExpanded(false);//悬浮tab展开
                if (popup != null) {
                    if (popup.isShowing()) {
                        popup.dismiss();
                        popup = null;
                    } else {
                        showPopup();
                    }
                } else {
                     /*弹框*/
                    showPopup();
                }
                MobclickAgent.onEvent(getActivity(), "ShopPrice", "商店价格");
                break;
            case R.id.rb_degree_of_heate:
                /*热度*/
                setIndexSelected(2);
                selectRadioButton(2);
                appBarLayout.setExpanded(false);//悬浮tab展开
                drawable_price = getResources().getDrawable(R.drawable.icon_default);
                drawable_price.setBounds(0, 0, 30, 50);//第一0是距左右边距离，第二0是距上下边距离，第三69长度,第四宽度
                rb_price.setCompoundDrawables(null, null, drawable_price, null);//只放上面
                if (heat_temperature == 0) {
                    heat_temperature = 1;
                    bean2.setSortType("2");
                    EventBus.getDefault().post(bean2);
                    drawable_degree_of_heate = getResources().getDrawable(R.drawable.icon_top);
                    drawable_degree_of_heate.setBounds(0, 0, 30, 50);//第一0是距左右边距离，第二0是距上下边距离，第三69长度,第四宽度
                    rb_degree_of_heate.setCompoundDrawables(null, null, drawable_degree_of_heate, null);//只放上面
                } else {
                    heat_temperature = 0;
                    bean2.setSortType("3");
                    EventBus.getDefault().post(bean2);
                    drawable_degree_of_heate = getResources().getDrawable(R.drawable.icon_bottom);
                    drawable_degree_of_heate.setBounds(0, 0, 30, 50);//第一0是距左右边距离，第二0是距上下边距离，第三69长度,第四宽度
                    rb_degree_of_heate.setCompoundDrawables(null, null, drawable_degree_of_heate, null);//只放上面
                }
                MobclickAgent.onEvent(getActivity(), "ShopDegreeOfHeate", "商店热度");
                break;
            case R.id.go_search:
                Intent inetent = new Intent(getActivity(), SearchProductActivity.class);
                startActivity(inetent);
                MobclickAgent.onEvent(getActivity(), "ShopSearch", "商店搜索");
                break;
            case R.id.img_furniture:
                /*家具*/
                categoryId = "1709121807451000006";
                Intent intent = new Intent(getActivity(), ProductClassificationActivity.class);
                intent.putExtra("categoryId", categoryId);
                intent.putExtra("title", "家具");
                startActivity(intent);
                SharePreferencesHelper.getInstance(getActivity()).putString("productCategoryId", categoryId);
                map.put("type", "家具");
                MobclickAgent.onEvent(getActivity(), "CommodityClassification", map);
                break;
            case R.id.img_home_furnishing:
                /*家居*/
                categoryId = "1709121816351000020";
                Intent furnishingIntent = new Intent(getActivity(), ProductClassificationActivity.class);
                furnishingIntent.putExtra("categoryId", categoryId);
                furnishingIntent.putExtra("title", "家居");
                startActivity(furnishingIntent);
                SharePreferencesHelper.getInstance(getActivity()).putString("productCategoryId", categoryId);
                map.put("type", "家居");
                MobclickAgent.onEvent(getActivity(), "CommodityClassification", map);
                break;
            case R.id.img_digital:
                /*数码*/
                categoryId = "1709121823431000047";
                Intent digitalIntent = new Intent(getActivity(), ProductClassificationActivity.class);
                digitalIntent.putExtra("categoryId", categoryId);
                digitalIntent.putExtra("title", "数码");
                startActivity(digitalIntent);
                SharePreferencesHelper.getInstance(getActivity()).putString("productCategoryId", categoryId);
                map.put("type", "数码");
                MobclickAgent.onEvent(getActivity(), "CommodityClassification", map);
                break;
            case R.id.img_jewellery:
                /*珠宝*/
                categoryId = "1803131633391010222";
                Intent jewelleryIntent = new Intent(getActivity(), ProductClassificationActivity.class);
                jewelleryIntent.putExtra("categoryId", categoryId);
                jewelleryIntent.putExtra("title", "珠宝");
                startActivity(jewelleryIntent);
                SharePreferencesHelper.getInstance(getActivity()).putString("productCategoryId", categoryId);
                map.put("type", "珠宝");
                MobclickAgent.onEvent(getActivity(), "CommodityClassification", map);
                break;
            case R.id.img_accessories:
                /*配饰*/
                categoryId = "1709121819121000031";
                Intent accessoriesIntent = new Intent(getActivity(), ProductClassificationActivity.class);
                accessoriesIntent.putExtra("categoryId", categoryId);
                accessoriesIntent.putExtra("title", "配饰");
                startActivity(accessoriesIntent);
                SharePreferencesHelper.getInstance(getActivity()).putString("productCategoryId", categoryId);
                map.put("type", "配饰");
                MobclickAgent.onEvent(getActivity(), "CommodityClassification", map);
                break;
            case R.id.img_originality:
                /*创意*/
                categoryId = "1803191002241010364";
                Intent originalityIntent = new Intent(getActivity(), ProductClassificationActivity.class);
                originalityIntent.putExtra("categoryId", categoryId);
                originalityIntent.putExtra("title", "创意");
                startActivity(originalityIntent);
                SharePreferencesHelper.getInstance(getActivity()).putString("productCategoryId", categoryId);
                map.put("type", "创意");
                MobclickAgent.onEvent(getActivity(), "CommodityClassification", map);
                break;
            case R.id.img_art:
                /*艺术*/
                categoryId = "1803191002491010366";
                Intent artIntent = new Intent(getActivity(), ProductClassificationActivity.class);
                artIntent.putExtra("categoryId", categoryId);
                artIntent.putExtra("title", "艺术");
                startActivity(artIntent);
                SharePreferencesHelper.getInstance(getActivity()).putString("productCategoryId", categoryId);
                map.put("type", "艺术");
                MobclickAgent.onEvent(getActivity(), "CommodityClassification", map);
                break;

            default:
                break;
        }

    }

    @Override
    protected void initData() {
        token = SharePreferencesHelper.getInstance(getActivity()).getString("token");
        loginState = SharePreferencesHelper.getInstance(getActivity()).getBoolean("loginState");
        fragments.add(new ComprehensiveCommodityFragment());
        fragments.add(new ComprehensiveCommodityFragment2());
        fragments.add(new ComprehensiveCommodityFragment3());
        radioButtons.add(rb_comprehensive);
        radioButtons.add(rb_price);
        radioButtons.add(rb_degree_of_heate);
        //开启事务

        FragmentTransaction ft =
                getActivity().getSupportFragmentManager().beginTransaction();

        //添加首页
        ft.add(R.id.content, new ComprehensiveCommodityFragment()).commit();

        //默认设置为第0个
        setIndexSelected(0);
        selectRadioButton(0);
        /*获取banner*/
        obtainBanner();
        /*获取首页专题活动*/
        obtainSpecial();


    }

    private void setIndexSelected(int index) {

        if (mIndex == index) {
            return;
        }
        FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();


        //隐藏
        ft.hide(fragments.get(mIndex));
        //判断是否添加
        if (!fragments.get(index).isAdded()) {
            ft.add(R.id.content, fragments.get(index)).show(fragments.get(index));
        } else {
            ft.show(fragments.get(index));
        }

        ft.commit();
        //再次赋值
        mIndex = index;

    }

    /*获取首页专题活动*/
    private void obtainSpecial() {
        ShareBean bean = new ShareBean();
        bean.setToken(token);
        CommonInterface messageInterface = new CommonInterface(getActivity(), specialListener);
        messageInterface.getInterface("13007", JSON.toJSONString(bean));

    }

    /*获取banner*/
    private void obtainBanner() {
        ShareBean bean = new ShareBean();
        bean.setToken(token);
        bean.setType("1");
        CommonInterface messageInterface = new CommonInterface(getActivity(), bannerListener);
        messageInterface.getInterface("13006", JSON.toJSONString(bean));
        picList = new ArrayList<>();
        picLocalList = new ArrayList<>();
    }
    /*价格弹框*/

    private void showPopup() {
        View view = View.inflate(getActivity(), R.layout.popupwindow_price_sort, null);
        final View view_pellucidity = view.findViewById(R.id.view_pellucidity);
        layout_empty = (RelativeLayout) view.findViewById(R.id.layout_empty);
        tv_confirm = (TextView) view.findViewById(R.id.tv_confirm);
        bg_ascending = (RelativeLayout) view.findViewById(R.id.bg_ascending);
        bg_descending = (RelativeLayout) view.findViewById(R.id.bg_descending);
        tv_ascending = (TextView) view.findViewById(R.id.tv_ascending);
        tv_descending = (TextView) view.findViewById(R.id.tv_descending);
        et_lower_price = (EditText) view.findViewById(R.id.et_lower_price);
        et_higher_price = (EditText) view.findViewById(R.id.et_higher_price);
        popup = new DatePopup(getActivity(), view);
        // 设置点击窗口外边窗口消失
        popup.setBackgroundDrawable(new BitmapDrawable());
        popup.setOutsideTouchable(true);
        // 设置此参数获得焦点，否则无法点击
        popup.setFocusable(true);
        //以某个控件的x和y的偏移量位置开始显示窗口
        popup.showAsDropDown(layout_search, 0, 140);
        //如果窗口存在，则更新
        popup.update();
        et_lower_price.setText(lower_price);
        et_higher_price.setText(higher_price);
        if (price_temperature == 0) {
            bg_ascending.setBackground(getResources().getDrawable(R.drawable.fen_border));
            tv_ascending.setTextColor(getResources().getColor(R.color.color_F91D48));
        } else {
            bg_descending.setBackground(getResources().getDrawable(R.drawable.fen_border));
            tv_descending.setTextColor(getResources().getColor(R.color.color_F91D48));
        }

        popup.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                view_pellucidity.setVisibility(View.GONE);
            }
        });
        view_pellucidity.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (popup != null) {
                    if (popup.isShowing()) {
                        popup.dismiss();
                        popup = null;
                    }
                }
                view_pellucidity.setVisibility(View.GONE);
                return true;
            }
        });
        view_pellucidity.setVisibility(View.VISIBLE);
        layout_empty.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                et_lower_price.setText("");
                et_higher_price.setText("");
                lower_price = "";
                higher_price = "";
                price_temperature = 0;
                bg_ascending.setBackground(getResources().getDrawable(R.drawable.fen_border));
                tv_ascending.setTextColor(getResources().getColor(R.color.color_F91D48));
                bg_descending.setBackground(getResources().getDrawable(R.drawable.hui_border));
                tv_descending.setTextColor(getResources().getColor(R.color.color_999999));
            }
        });
        tv_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                drawable_degree_of_heate = getResources().getDrawable(R.drawable.icon_default);
                drawable_degree_of_heate.setBounds(0, 0, 30, 50);//第一0是距左右边距离，第二0是距上下边距离，第三69长度,第四宽度
                rb_degree_of_heate.setCompoundDrawables(null, null, drawable_degree_of_heate, null);//只放上面
                lower_price = et_lower_price.getText().toString();
                higher_price = et_higher_price.getText().toString();
                if (lower_price.equals("")) {

                    lower_price = "0";
                    lower = 0;
                    et_lower_price.setText("0");
                } else {
                    lower = Integer.parseInt(lower_price);
                }
                if (higher_price.equals("")) {
                    higher_price = "";
                    higher = 0;
                    et_higher_price.setText("0");
                } else {
                    higher = Integer.parseInt(higher_price);
                }
                if (lower > higher) {
                    ToastUtil.showToast("输入错误，最低价不高于最高价");
                } else {
                    setIndexSelected(1);
                    selectRadioButton(1);
                    if (price_temperature == 0) {
                        drawable_price = getResources().getDrawable(R.drawable.icon_top);
                        drawable_price.setBounds(0, 0, 30, 50);//第一0是距左右边距离，第二0是距上下边距离，第三69长度,第四宽度
                        rb_price.setCompoundDrawables(null, null, drawable_price, null);//只放上面
                        bean.setSortType("5");
                        bean.setMinPrice(lower_price);
                        bean.setMaxPrice(higher_price);
                        EventBus.getDefault().post(bean);
                        popup.dismiss();

                    } else {
                        drawable_price = getResources().getDrawable(R.drawable.icon_bottom);
                        drawable_price.setBounds(0, 0, 30, 50);//第一0是距左右边距离，第二0是距上下边距离，第三69长度,第四宽度
                        rb_price.setCompoundDrawables(null, null, drawable_price, null);//只放上面
                        bean.setSortType("4");
                        bean.setMinPrice(lower_price);
                        bean.setMaxPrice(higher_price);
                        EventBus.getDefault().post(bean);
                        popup.dismiss();
                    }
                    SharePreferencesHelper.getInstance(getActivity()).putString("sortType", bean.getSortType());
                    SharePreferencesHelper.getInstance(getActivity()).putString("lower_price", lower_price);
                    SharePreferencesHelper.getInstance(getActivity()).putString("higher_price", higher_price);
                }

            }


        });
        bg_ascending.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                 /*升序*/
                price_temperature = 0;
                bg_ascending.setBackground(getResources().getDrawable(R.drawable.fen_border));
                tv_ascending.setTextColor(getResources().getColor(R.color.color_F91D48));
                bg_descending.setBackground(getResources().getDrawable(R.drawable.hui_border));
                tv_descending.setTextColor(getResources().getColor(R.color.color_999999));
            }
        });
        tv_descending.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    /*降序*/
                price_temperature = 1;
                bg_descending.setBackground(getResources().getDrawable(R.drawable.fen_border));
                tv_descending.setTextColor(getResources().getColor(R.color.color_F91D48));
                bg_ascending.setBackground(getResources().getDrawable(R.drawable.hui_border));
                tv_ascending.setTextColor(getResources().getColor(R.color.color_999999));
            }
        });

    }

    /*bannner*/
    HttpListener bannerListener = new HttpListener() {
        @Override
        public void OnSuccess(String response) {
            super.OnSuccess(response);
            String errCode = JsonUtil.getFieldValue(response, "errCode");
            String errMsg = JsonUtil.getFieldValue(response, "errMsg");
            if (errCode.equals("0000")) {
                bannerBean = JsonUtil.parseJsonToBean(response, ListBean.class);
                if (bannerBean.getBannerList().size() == 0) {
                    picLocalList.add(R.drawable.symbols_bitmap);
                    banner.setImages(picLocalList);
                    banner.setOnItemClickListener(null);
                } else {
                    for (int i = 0; i < bannerBean.getBannerList().size(); i++) {
                        picList.add(bannerBean.getBannerList().get(i).getImgUrl());
                    }
                    banner.setImagesUrl(picList);

                }


            } else {
                closeLoadingDialog();
                toast(errMsg);
            }
        }

        @Override
        public void OnFail(String errorResponse) {
            super.OnFail(errorResponse);
        }
    };

    HttpListener specialListener = new HttpListener() {
        @Override
        public void OnSuccess(String response) {
            super.OnSuccess(response);
            String errCode = JsonUtil.getFieldValue(response, "errCode");
            String errMsg = JsonUtil.getFieldValue(response, "errMsg");
            if (errCode.equals("0000")) {

                ListBean bean = JsonUtil.parseJsonToBean(response, ListBean.class);
                dataBean.addAll(bean.getProductSubjectList());
                productSubjectAdapter.notifyDataSetChanged();

            } else {
                closeLoadingDialog();
                toast(errMsg);
            }
        }

        @Override
        public void OnFail(String errorResponse) {
            super.OnFail(errorResponse);
        }
    };

    /**
     * 设置当前选中的radiobutton的文字颜色
     *
     * @param i
     */
    private void selectRadioButton(int i) {
        for (int j = 0; j < 3; j++) {
            if (j == i) {
                radioButtons.get(j).setTextColor(getResources().getColor(R.color.sjs_text));
                radioButtons.get(j).setChecked(true);
            } else {
                radioButtons.get(j).setTextColor(getResources().getColor(R.color.home_text));
            }
        }


    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();

        //结束任务
        if (productSubjectAdapter != null)
            productSubjectAdapter.cancelAllTimers();
    }
}
